package com.wey.springboot.listener;

import com.wey.springboot.service.MessageRemindService;
import lombok.SneakyThrows;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class QuartzTaskLoadListener implements ApplicationListener<ContextRefreshedEvent> {
  @Autowired
  Scheduler scheduler;

  @Autowired
  MessageRemindService messageRemindService;

  @SneakyThrows
  @Override
  public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
    messageRemindService.loadTask();
    scheduler.start();
  }
}
